// 生成指定长度的随机大写字母字符串
export const generateRandomString = (length) => {
  return Array.from({ length }, () => 
    String.fromCharCode(65 + Math.floor(Math.random() * 26))
  ).join('')
}

// 生成随机时间（过去30天内）
export const randomTime = () => {
  const now = new Date()
  const randomOffset = Math.floor(Math.random() * 30 * 24 * 60 * 60 * 1000)
  const randomDate = new Date(now - randomOffset)
  
  return randomDate.toLocaleString('zh-CN', {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit',
    hour: '2-digit',
    minute: '2-digit',
    second: '2-digit'
  }).replace(/\//g, '-')
}

// 生成服务器模拟数据
export const mockServerData = (count = 2) => {
  return Array.from({ length: count }, () => ({
    id: generateRandomString(10),
    os: Math.random() > 0.5 ? 'Windows' : 'Linux',
    bootTime: randomTime(),
    cpu: Math.floor(Math.random() * 40) + 10, // 10-50
    memory: Math.floor(Math.random() * 800) + 100, // 100-900
    version: generateRandomString(5),
    tasks: Math.floor(Math.random() * 20) + 1
  }))
}

// 生成子任务模拟数据
export const mockSubTasks = (count = 2) => {
  return Array.from({ length: count }, () => ({
    subtaskId: generateRandomString(10),
    parentTaskId: generateRandomString(10),
    os: Math.random() > 0.5 ? 'Windows' : 'Linux',
    queueTime: randomTime(),
    startTime: randomTime(),
    endTime: randomTime(),
    cpu: 1,
    memory: Math.floor(Math.random() * 150) + 50 // 50-200
  }))
}
